const path = require("path");
// const webpack = require("webpack");

function resolve(dir) {
	return path.join(__dirname, "./", dir);
}

module.exports = {
	productionSourceMap: false,
	configureWebpack: {
		plugins: [
			// new webpack.ProvidePlugin({
			//   $: 'jquery',
			//   jQuery: 'jquery',
			//   jquery: 'jquery',
			//   'window.jQuery': 'jquery'
			// })
		]
	},
	assetsDir: "static",
	chainWebpack: config => {
		config.resolve.alias
			.set("@", resolve("src"))
			.set("~", resolve("public"));
		config.module
			.rule("svg")
			.exclude.add(resolve("src/icons/svg"))
			.end();
		config.module
			.rule("icons")
			.test(/\.svg$/)
			.include.add(resolve("src/icons/svg"))
			.end()
			.use("svg-sprite-loader")
			.loader("svg-sprite-loader")
			.options({
				symbolId: "icon-[name]"
			});
	},
	devServer: {
		disableHostCheck: true,
		proxy: {
			"/api": {
				target: "http://localhost:28993/api", // 接口域名
				changeOrigin: true,
				pathRewrite: {
					"^/api": ""
				}
			}
		}
	}
};
